const app = getApp()
Component({
	options: {
		multipleSlots: true, // 在组件定义时的选项中启用多slot支持
	},
	properties: {
		isServer: {
			type: Boolean,
			value: false,
		},
	},
	data: {
		curPage: null,
		list: [ // 本地全部权限
			// { text: '首页', pathActive: 'icon-home', path: '../../images/v1/icon-home.png' },
			{
				text: '首页',
				component: 'home',
				iconActive: '../../assets/images/home-active.png',
				icon: '../../assets/images/home.png',
				path: 'tabBar/home/index',
			},
			{
				text: '业务',
				component: 'service',
				iconActive: '../../assets/images/member-active.png',
				icon: '../../assets/images/member.png',
				path: 'tabBar/service/index',
			},
			{
				text: '接口',
				component: 'API',
				iconActive: '../../assets/images/store-active.png',
				icon: '../../assets/images/store.png',
				path: 'tabBar/API/index',
			},
			{
				text: '组件',
				component: 'component',
				iconActive: '../../assets/images/my-active.png',
				icon: '../../assets/images/my.png',
				path: 'tabBar/component/index',
			},
		],
		renderData: [ // 无权限默认显示
      {
				text: '首页',
				component: 'home',
				iconActive: '../../assets/images/home-active.png',
				icon: '../../assets/images/home.png',
				path: 'tabBar/home/index',
			},
      {
				text: '组件',
				component: 'component',
				iconActive: '../../assets/images/my-active.png',
				icon: '../../assets/images/my.png',
				path: 'tabBar/component/index',
			},
    ],
	},
	observers: {},
	attached() {
		let _pages = getCurrentPages()
		let _arr = _pages[_pages.length - 1].route.split('/')
		let _key = _arr[1] + '/' + _arr[2] + '/' + _arr[3]
		let _list = this.data.list
		// if (
		// 	app.store.getStorage('userInfo') &&
		// 	app.store.getStorage('oneMenu')
		// ) {
		// 	let _oneMenu = app.store.getStorage('oneMenu')
		// 	_list = _list.filter((ele) => {
		// 		if (_oneMenu[ele.component]) {
		// 			return ele
		// 		}
		// 	})
			this.setData({
				renderData: _list,
			})
		// }

		this.setData({
			curPage: _key,
		})
	},
	methods: {
		/*属性监听*/
		/*逻辑事件*/
		/*接口请求*/
		/*页面交互*/
		tapNav(evt) {
			let _item = evt.currentTarget.dataset.item
			if (_item.path == this.data.curPage) return
      console.log('../../' + _item.path);
			wx.reLaunch({
				url: '../../' + _item.path,
			})
		},
		/*父级回调*/
		/*组件响应*/
	},
})
